﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.ComponentModel;

namespace Kokomo.Mirror.CliMetadata.Tables
{
	public class TypeDefRow : IMetadataRow
	{
		public TypeAttributes Flags { get; set; }
		public StringRef TypeName { get; set; }
		public StringRef TypeNamespace { get; set; }
		[CodedIndex(CodedIndexType.TypeDefOrRef)]
		public CodedIndex Extends { get; set; }

		[SimpleIndex(MetadataTableNumber.Field)]
		public CodedIndex FieldList { get; set; }

		[SimpleIndex(MetadataTableNumber.MethodDef)]
		public CodedIndex MethodList { get; set; }

		public string GetFullName(MetadataContainer container)
		{
			string ns = container.GetString(this.TypeNamespace);
			string name = container.GetString(this.TypeName);

			if (ns == null) return name;
			else return string.Format("{0}.{1}", ns, name);
		}
		public override string ToString(MetadataContainer container)
		{
			return this.GetFullName(container);
		}
	}
}
